/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.migracion.pool;

import org.antlr.stringtemplate.StringTemplate;

/**
 *
 * @author stevenziggiz
 */
public class Oracle extends DriverConnectionPool implements DataBaseConnection {

    static {
        DATA_BASE_TYPE = "Oracle";
    }

    private Oracle() {
        setTablesList("Select * FROM all_tables Where OWNER = '" + this.getDataBaseName() + "'; ORDER BY table_name;");
        setColumnsList("Select column_name, data_type, nullable FROM all_tab_columns Where OWNER = '" + this.getDataBaseName() + "' AND table_name = '$TABLE_PARAM$';");
    }

    public Oracle(String ipServer, int port, String serviceName, String dataBaseName, String user, String password) {
        DRIVER_NAME = "oracle.jdbc.driver.OracleDriver";
        URL = new StringTemplate("jdbc:oracle:thin:@//$HOST$:$PORT$/$SERVICE$");
        //Cambia las variables definidas en el Template por los valores correspondientes
        URL.setAttribute("HOST", ipServer);
        URL.setAttribute("PORT", port);
        URL.setAttribute("SERVICE", serviceName);
        this.user = user;
        this.password = password;
        this.setDataBaseName(dataBaseName);
        setTablesList("Select * FROM all_tables Where OWNER = '" + this.getDataBaseName() + "' ORDER BY table_name");
        setColumnsList("Select column_name, data_type, nullable FROM all_tab_columns Where table_name = '$TABLE_PARAM$'");
    }
}
